package cn.blackpears.modelprotection;

import org.bukkit.block.Chest;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent;

public class Protection implements Listener {
    @EventHandler(priority=EventPriority.HIGH)
    public void onInventoryOpen(InventoryOpenEvent e){
        if (!(e.getPlayer() instanceof Player)) {
            return;
        }
        if((e.getInventory().getType() == InventoryType.CHEST)){
            if(!e.getPlayer().isOp()) {
                if(!Verification.BTN.equalsIgnoreCase("Chest")) {
                    e.setCancelled(true);
                    ((Player) e.getPlayer()).closeInventory();
                    e.getPlayer().sendMessage("模特被禁用");
                }else{
                    Verification.BTN = "WOOL";
                    return;
                }
            }
        }
    }
}
